package main;

import javax.swing.JPanel;

import GUI.AdminScreen;
import GUI.CustomerScreen;
import GUI.EmployeeScreen;
import GUI.LogInScreen;
import GUI.TabPanels.AdminTabs.CreateCustomerAccountPanel;

@SuppressWarnings("serial")
public class ScreenController extends JPanel{
	private LogInScreen login;
	private CreateCustomerAccountPanel customer_account_panel;
	private static ScreenController instance = null;
	private AdminScreen admin;
	private EmployeeScreen emplo;
	private CustomerScreen customer;
	
	private ScreenController(){
	}
	
	public static ScreenController getInstance(){
		if(instance == null)
			instance = new ScreenController();
		return instance;
	}
	
	public void InitializePanels(){
		login = LogInScreen.getInstance();
		customer_account_panel = new CreateCustomerAccountPanel();
		this.add(login);
	}
	
	public void InitializeAdminPanel(){
		admin = new AdminScreen();
	}
	
	public void InitializeEmployeePanel(){
		emplo = new EmployeeScreen();
	}
	
	public void InitializeCustomerPanel(int ID){
		customer = CustomerScreen.getInstance();
		customer.setID(ID);
		customer.initializePanels();
	}
	
	public void ViewLoginScreen(){
		if(admin != null)
			this.remove(admin);
		if(emplo !=null)
			this.remove(emplo);
		if(customer !=null)
			this.remove(customer);
		if(customer_account_panel !=null)
			this.remove(customer_account_panel);
		emplo = null;
		admin = null;
		this.add(login);
		repaint();
		this.setVisible(false);
		this.setVisible(true);
	}
	
	public void AddCustomerAccount(){
		this.remove(login);
		this.add(customer_account_panel);
		repaint();
		this.setVisible(false);
		this.setVisible(true);
	}
	public void ViewAdminScreen(){
		this.remove(login);
		this.add(admin);
		repaint();
		this.setVisible(false);
		this.setVisible(true);
	}
	public void ViewEmployeeScreen(){
		this.remove(login);
		this.add(emplo);
		repaint();
		this.setVisible(false);
		this.setVisible(true);
	}
	public void ViewCustomerScreen(){
		this.remove(login);
		this.add(customer);
		repaint();
		this.setVisible(false);
		this.setVisible(true);
	}
}
